#pragma once

#include "Business/IDealingHandler.h"

class MarketStorage;
class Funds;
class Trade;
class Dealing;
class CustomerPosition;
class Leg;

class FundsService : public IDealingHandler
{
public:
	FundsService(MarketStorage const& marketStorage)
		:m_marketStorage(marketStorage)
	{
	}
	static double FreezeDealingFund(MarketStorage const& marketStorage,Dealing const& dealing);
	int GetOperation(Trade const& trade);
private:
	virtual void DoOnDealing(Dealing const& dealing);
	virtual void DoOnTrade(Trade const& trade);

	void OnOpenTrade(Trade const &trade);
	void OnOffsetTrade(Trade const &trade);
	double CalcTradeProfit(Trade const& trade, double openPrice);
	double CalcTradeCharge(Trade const &trade);
private:
	MarketStorage const& m_marketStorage;
};